<template>
    <el-form ref="form" :model="form" label-width="100px">

        <el-form-item label="任务名称">
            <el-input v-model="form.name"></el-input>
        </el-form-item>


        <el-form-item label="操作目标">
            <el-input v-model="form.taskTarget" placeholder="数字,多个之间用 ',' 隔开"></el-input>
        </el-form-item>

        <el-form-item label="操作">
            <el-input disabled placeholder="模拟测试，使 id 为 目标字段+1" readonly></el-input>
        </el-form-item>

        <el-form-item label="任务类型">
            <el-select v-model="form.taskType" placeholder="请选择任务类型">
                <el-option :value="1" label="执行一次"></el-option>
                <el-option :value="2" label="定期执行"></el-option>
            </el-select>
        </el-form-item>
        <!--  -->
        <div v-show="form.taskType===1">
            <el-form-item label="执行日期">
                <el-input v-model="form.taskTime"></el-input>
            </el-form-item>
        </div>

        <div v-show="form.taskType===2">
            <el-form-item label="多久执行(秒)">
                <el-input v-model="form.taskLoop"></el-input>
            </el-form-item>
        </div>


        <el-form-item>
            <el-button type="primary" @click="onSubmit">立即创建</el-button>
            <el-button>取消</el-button>
        </el-form-item>
    </el-form>
</template>
<script>
    export default {
        data () {
            return {
                form: {
                    name: '',
                    taskType: '',
                    taskTime: null,
                    taskLoop: null
                }
            }
        },
        methods: {
            onSubmit () {
                $.post(HOST + '/task', this.form, (resp) => {
                    console.log(resp)
                })
            }
        }
    }
</script>
